﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using WPFExcelReport.Helpers;
namespace WPFExcelReport
{
    /// <summary>
    /// 查看支付记录，支付记录本身与应收/应付行对应，属于附属表
    /// </summary>
    public partial class TVRPAY
    {

        public TVRPAY()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VVRPOS();
            DataContext = MV;
            InitializeComponent(); 
        }
        public override void vwMaster_CurrentChanged(object sender, System.EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
        }
        public override void NewCommand(object sender, RoutedEventArgs e)
        {
            if (SVALUE == 0)
            {
                PAIDVALUE = "";
                待处理现金 = 待处理现金 + SVALUE;//首先记入待处理现金
                PAIDVALUE = PAYTYP.PadRight(10) + SVALUE.ToString().PadRight(20); 
                return;
            } 
            if(QTY==0)
            {
                MessageBox.Show("请输入等值的数量");
                return;
            }
            IsNew = true; 
            base.NewCommand(sender, e);
            PAIDVALUE = "";
            待处理现金 = 待处理现金+ SVALUE;//首先记入待处理现金
            PAIDVALUE = PAYTYP.PadRight(10) + SVALUE.ToString().PadRight(20);
            SVALUE = 0;
        }
        public override void LOADBYVKP(string vkp)
        {
            TBMain.Clear();
             if (vkp.Length < 11)
                return;
            dwData = TBMain.NewRow();
            dwData["VRPMANDANT"] = app.Mandant;
            dwData["VRPSTATIST"] = vkp.Substring(0, 1);
            dwData["VRPAUFKRS"] = vkp.Substring(1, 2);
            dwData["VRPAUFLFD"] = vkp.Substring(3, 6);
            dwData["VRPAUFPOS"] = vkp.Substring(9, 3);
            dwData["VRPZOLLTNR"] = " AND VRPZOLLTNR LIKE '7:%'";
            SResult = TMV.QVRP04(dwData);
            MergeData(SResult, true);
        }
        public override void OnEXAUFChg(string value)
        { 
            TBMain.Clear();
             if (value.Length < 11)
                return;
            dwData = TBMain.NewRow();
            dwData["VRPMANDANT"] = app.Mandant;
            dwData["VRPRENR"] = value.Substring(0, 8);
            dwData["VRPREPOS"] = value.Substring(8, 3); 
            SResult = TMV.QVRP05(dwData);
            MergeData(SResult, true); 
            base.OnEXAUFChg(value);
        }
    }
}